# coding=utf-8

import arcpy
import os
import uuid
from base.BaseTool import select_from_shp, add_field, calculate_field, statistics_analysis,cut_raster
from multiprocessing import Pool

if __name__ == '__main__':
    print ("开始执行")

    # 复制栅格
    # out_raster = arcpy.Raster("E:/测试数据/无人机影像/0926_01.tif")
    # print ("开始执行")
    # out_raster.save("E:/测试数据/无人机影像/0926_03.tif")
    # print ("执行完成")
    #
    # 复制矢量数据
    # feature_set = arcpy.FeatureSet()
    # feature_set.load("D:/arcgisworkplace/new.shp")
    # feature_set.save("E:/temp/newcopy.shp")
    # 添加字段 https://desktop.arcgis.com/zh-cn/arcmap/latest/tools/data-management-toolbox/add-field.htm
    # arcpy.AddField_management("D:/arcgisworkplace/new.shp", "LEN", "DOUBLE",  field_is_nullable="NULLABLE")
    # 计算字段 https://desktop.arcgis.com/zh-cn/arcmap/latest/tools/data-management-toolbox/calculate-field.htm
    # arcpy.CalculateField_management("D:/arcgisworkplace/new.shp", "LEN", "!Shape_Area!", "PYTHON_9.3")
    # print(os.path.dirname(os.path.dirname("D:/arcgisworkplace/new.shp"))),
    # print (select_from_shp("E:/temp/oss/3D96C7675EAF4E04A0EB60402E8D953E/new.shp", '"FID" = 4'))
    # drink_process = multiprocessing.Process(target=select_from_shp,
    #                                         kwargs={'shp_path': 'E:/temp/oss/3D96C7675EAF4E04A0EB60402E8D953E/new.shp',
    #                                                 'exp': '"FID" = 4'})
    # drink_process.start()
    # drink_process.join()

    # pool = Pool(processes=1)
    # # task = pool.apply_async(select_from_shp, ('E:/temp/oss/3D96C7675EAF4E04A0EB60402E8D953E/new.shp', '"FID" = 4'))
    # # drink_process = multiprocessing.Process(target=select_from_shp,
    # #                                         kwargs={
    # #                                             'shp_path': 'E:/temp/oss/3D96C7675EAF4E04A0EB60402E8D953E/new.shp',
    # #                                             'exp': '"FID" = 4'})
    # pool.close()
    # pool.join()
    # print (add_field('E:/temp/oss/3D96C7675EAF4E04A0EB60402E8D953E/new.shp', 'NAMSE', 'DOUBLE'))
    # arcpy.Select_analysis('E:/测试数据/武汉市区/居民地域.shp',
    #                       'E:/temp/oss/91ed78178b3544959c7e607c318ba3334.shp',
    #                       '"ID" = 17118')
    # print ("执行完成")
    # # print (task.get())
    # path = "E:/temp/oss/3D96C7675EAF4E04A0EB60402E8D953E/new.shp"
    # index = path.rfind(".")
    # print path[index:]

    # print calculate_field("E:\\temp\\oss/aef0345578a64d8984861cc8457d311d/0e34483ebce749aca7ec3fbda1afc02d.dbf", "SUM_area", "[SUM_area]/15","VB")
    # path = add_field('E:/temp/oss/05A998AC188047DBB5535C2BB7F9DC1A/ykm_zyq.shp', 'area', 'DOUBLE')
    # path = calculate_field(path, "area", "!shape!.area")
    # print statistics_analysis(path, "area", "SUM")

    print cut_raster("E:/测试数据/0926_01.tif", "E:/测试数据/Crop.shp")
    # arcpy.copy(input="D:/arcgisworkplace/new.shp", output="E:/temp/newcopy.shp")
